<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta
	http-equiv="Content-Type"
	content="text/html; charset=UTF-8">
<link
	rel="stylesheet"
	type="text/css"
	href="./style.css"
	media="screen" />
<title>Spring Fit Demo</title>
</head>
<body>

This is used to load the Spring configuration:
<br>
<br>
<table
	border="1"
	cellspacing="0">
	<tr>
		<td>springfixture.SpringConfig</td>
	</tr>
	<tr>
		<td>beans.xml</td>
	</tr>
</table>
<br>
<br>
This is the SpringColumnAdapter. It automatically makes a Spring Bean
accessible for Fit/FitNesse as a ColumnFixture. Columns that do not end
with a question mark (?) are assumed to contain test data. This is
collected until a method is accessed using a column that ends in a
questions mark (?). Then these values are used to populate the
parameters for this call. The result of the call are converted to String
an then matched with the content of the cell.
<br>
This way a Spring Bean can be tested without any further effort provided
that the parameters are not too complex i.e. no complex properties are
needed. Also the parameters must be declared as the concrete classes
i.e. the parameter class is instatiated.
<br>
<br>
<table
	border="1"
	cellspacing="0">
	<tr>
		<td colspan="3">springfixture.SpringColumnFixture</td>
	</tr>
	<tr>
		<td colspan="3">playerList</td>

	</tr>
	<tr>
		<td>name</td>
		<td>add?</td>
		<td>countPlayers?</td>
	</tr>
	<tr>
		<td>Wolff</td>
		<td class="pass">&nbsp;</td>
		<td class="pass">1</td>
	</tr>
</table>
<br>
Now we want to use a "normal" Fixture, a subclass of TabelFixture. This
object should have other objects dependecy injected. This is done by
using the @Configurable Annotation.
<table
	border="1"
	cellspacing="0">
	<tr>
		<td>eg.ListPlayers</td>
	</tr>
	<tr>
		<td>name</td>
	</tr>
	<tr>
		<td class="pass">Wolff</td>
	</tr>
</table>
To make this work, you need to use the AspectJ Load Time Weaver.
Basically this means to pass
<tt>-javaagent:&lt;path-to-ajlibs&gt;/aspectjweaver.jar</tt>
to the JVM as a VM parameter. For more details see
<a
	href="http://static.springframework.org/spring/docs/2.0.x/reference/aop.html#aop-atconfigurable">the
Spring Reference Documentation</a>
. Be careful: You can only have one ApplicationContext per ClassLoader
that can be used in conjunction with @Configurable. Using this feature
therefore limits you to one ApplicationContext, see
<a
	href="http://static.springframework.org/spring/docs/2.0.x/reference/aop.html#d0e9239">http://static.springframework.org/spring/docs/2.0.x/reference/aop.html#d0e9239</a>
.
<br>
<br>
<table
	border="1"
	cellspacing="0">
	<tr>
		<td colspan="3">springfixture.SpringActionFixture</td>
	</tr>
	<tr>
		<td colspan="3">playerList</td>

	</tr>
	<tr>
		<td>enter</td>
		<td>name</td>
		<td>Johnson</td>
	</tr>
	<tr>
		<td>enter</td>
		<td>birthdate</td>
		<td>01.01.1950</td>
	</tr>
	<tr>
		<td>enter</td>
		<td>address.city</td>
		<td>London</td>
	</tr>
	<tr>
		<td>press</td>
		<td colspan="2" class="pass">add</td>
	</tr>
	<tr>
		<td>check</td>
		<td>countPlayers</td>
		<td class="pass">2</td>
	</tr>
	<tr>
		<td>enter</td>
		<td>name</td>
		<td>Johnson</td>
	</tr>
	<tr>
		<td>press</td>
		<td colspan="2" class="pass">getPlayerByName</td>
	</tr>
	<tr>
		<td>check</td>
		<td>birthdate</td>
		<td class="pass">01.01.1950</td>
	</tr>
	<tr>
		<td>enter</td>
		<td>id</td>
		<td>1</td>
	</tr>
	<tr>
		<td>press</td>
		<td colspan="2" class="pass">getPlayerById</td>
	</tr>
	<tr>
		<td>check</td>
		<td>name</td>
		<td class="pass">Johnson</td>
	</tr>
	<tr>
		<td>check</td>
		<td>address.city</td>
		<td class="pass">London</td>
	</tr>
	<td>
</table>
<p>This demo show what you can do with the integration: You take the
Spring Bean <tt>playerList</tt> and build an action script based on it.</p>
<p>First an environment is set up. Here the name and the birthdate
are given. This is then used to fill up value objects. What is happening
is that automatically an instance of each class passed to the method is
created. Then the properties of this instance are filled. For this the
entries in the environment are used.</p>
<p>The birthdate is treated in a special way: Because there is a <tt>PropertyEditor</tt>
registered by the <tt>eg.CustomDatePropertyEditorRegistrar</tt> given in
the configuration it is automatically handled by this property editor.</p>
<p>After a method is called that gives a complex result like a <tt>getPlayerById</tt>
the result is added to the environment so the following <tt>check</tt>
entries work by using this result of this method call.</p>
<p>Note that due to Spring's <tt>BeanWrapperImpl</tt> even embedded
properties like address.city work.</p>
</body>
</html>
